﻿using System;
using System.Collections.Generic;

namespace NothingButBank
{
    public class Account
    {
        private double currentBalance;
        private readonly List<AccountTransaction> transactionList = new List<AccountTransaction>();

        public double CurrentBalance
        {
            get { return currentBalance; }
            set { currentBalance = value; }
        }

        public Account()
        {
            currentBalance = 0;
        }

        public void Deposit(DateTime date, double amount)
        {
            AccountTransaction transaction = new AccountTransaction(date, amount);
            transactionList.Add(transaction);
        }

        public void Withdraw(DateTime date, double amount)
        {
            if (currentBalance >= amount)
            {
                AccountTransaction transaction = new AccountTransaction(date, amount * -1);
                transactionList.Add(transaction);
            }
            else
            {
                throw new InvalidOperationException("Withdrawal amount cannot exceed Current Balance");
            }
        }
    }
}
